<template>
  <div style="background-color: rgba(217,203,184,0.27)">
    <sg-nav></sg-nav>
    <div>
      <el-row>
        <el-col :sm="24" :md="13" style="transition:all .5s ease-out;margin-bottom:30px;">
          <el-row class="baikeDetailBox">
            <el-col :span="24" class="s-item tcommonBox" v-for="help in helpList ":key="'help'+help.id">
              <header>
                <h1>
                  {{help.title}}
                </h1>
                <h2>{{help.createTime}}</h2>
                <h3> {{help.likeCount}} 次点赞 •</h3>
                <img v-if="help.thumbnail" :src="help.thumbnail" alt="" width="400"height="350">
              </header>
              <div class="article-content markdown-body" v-html="help.content"></div>
<!--              <el-button-->
<!--                  class="el-icon-edit"-->
<!--                  type="text"-->
<!--                  size="medium"-->
<!--                  plain-->
<!--                  @click="$refs.writeDiaryDialog.open(null,diary,1)"-->
<!--              >编辑日记</el-button>-->
            </el-col>
          </el-row>
        </el-col>
        <el-col :sm="8"  :md="6" >
          <sg-rightList></sg-rightList>
        </el-col>
      </el-row>
    </div>
<!--    <write-diary-dialog ref="writeDiaryDialog" title="编辑日记"  @confirmData="(plantDiary1,fileList) => updatePlantDiary(plantDiary1)"></write-diary-dialog>-->
  </div>
</template>

<script>
import {getArticle, updateViewCount} from "@/api/article";
import {getQAList} from "@/api/question_answer";
import Header from "@/components/common/Header";
import rightList from "@/components/common/RightList";

export default {
  name: "HelpPage",
  components:{
    'sg-nav':Header,
    'sg-rightList':rightList,
  },
  data(){
    return{
      helpList:[],
      aid:'',
    }
  },
  created() {
    this.routeChange();
  },
  methods:{
    getHelpList(aid){
      console.log("aid:",aid)
      //var hlist=[]
      getQAList(aid).then(res=>{
        console.log(res)
        for(const element of res) {
          getArticle(element.answerId).then(res=>{
            console.log(res)
            this.helpList.push(res)
          })
        }
        //console.log(this.helpList)
      })
    },
    routeChange:function(){
      console.log("hhhidoe",this.$route.query.aid)
      var that = this;
      that.aid = that.$route.query.aid==undefined?0:parseInt(that.$route.query.aid);//获取传参的aid
      //判断用户是否存在
      //获取详情接口
      this.getHelpList(this.aid)
    }
  }
}
</script>

<style scoped>

</style>